/**
 * 作者: LDL
 * 说明:
 * 时间: 2015/7/18 17:46
 */
class HelloScala {

}

object HelloScala {

    def hello(name: String): String ={
        "Hello "+name;
    }

    def helloScala(): Unit ={
        println("Hello Scala,thi is rocky!");
    }
    def main(args: Array[ String ]) {
        println(hello("scala"))
        helloScala()
        helloScala
        println(add(1,2))
        println(sum(1,2))
        variableParameter("I","Love","spark")
        println(helloDefault())

        val max = 1;
        val result = if(max>0) 1 else 0
        println(result)

        var (n,r) = (10,0)
        while (n>0){
            r += n
            n -= 1
        }
        println(r)

        for(i<- 0 to 10){
            println(i)
        }

        for(i<- 1 until 10){
            println(i)
        }

        for(i<- 1 to 10 if i % 2 == 0){
            println(i)
        }
    }

    def add = (x:Int,y:Int)=>x+y;
    val sum = (x:Int,y:Int)=>x+y;
    def sum2(x:Int)(y:Int)=x+y;

    def variableParameter(s:String*): Unit ={
        s.foreach(x=>println(x))
    }

    def helloDefault(name:String="www.sparkinchina.com"):String={
        "Hello "+name
    }


}